import pandas as pd

def gettime(row):
    r = str(row).strip().split(" ")[0]
    return r
    pass
df = pd.read_csv('sales2.csv',sep=",",encoding="utf-8")
print(df.isnull().sum())

df = df.dropna(axis=0,how='any')
df['支付时间'] =df['支付时间'].apply(gettime)
df['支付时间'] = pd.to_datetime(df['支付时间'],format='%Y/%m/%d',errors='coerce')

df = df.set_index(df['支付时间'])
df_month = df.resample('M').size().to_period('M')
df_month = df_month.reset_index()
df_month.columns=['支付时间','订单数']
df_month.to_csv('month.csv',index=False)



